/**
 * Created by zzy on 2017/9/10.
 */
import React ,{Component} from 'react';
import {StackNavigator} from 'react-navigation';
import {AppState} from 'react-native';
import CodePushUtil from "./util/CodePushUtil";

global.LOG = (...args) => {
    console.log('**********************');
    console.log(...args);
    console.log('**********************');
    return args[args.length - 1];
};

import Tab from './tab';
import Login from './loginLuo/Login'
import WaterStation from '../luojs/station/WaterStation'
import ConfirmOrder from '../js/home/ConfirmOrder'
import QuickPay from '../js/home/QuickPay'
import PayResult from '../js/home/PayResult'
import AddressList from '../js/address/AddressList'
import TiketsViable from '../js/home/TiketsViable'
import TicketCell from './homeLuo/TicketCell'
import TiketList from './homeLuo/TicketList'
import TicketDetails from './homeLuo/TicketDetailsLuo'
import TicketDetail from './homeLuo/TicketdetailLuo'
import TicketPage from './homeLuo/TicketDetailPageLuo'
import ProductInfoLuo from './homeLuo/ProductInfoLuo'
import ProductsDetailsLuo from './homeLuo/ProductsDetailsLuo'
import DeliveryAddress from '../js/address/DeliveryAddress'
import AddOrEditAddress from '../js/address/AddOrEditAddress'
import Map from '../js/address/Map'
import HotSaleList from './homeLuo/HotSale'
import Collection from './meLuo/Collection'
import MyTiketsLuo from './meLuo/MyTiketsLuo'
import MyTiketsUsedLuo from './meLuo/MyTiketsUsedLuo'
import MyTicketDetail from './homeLuo/MyTicketDetail'
import ShoppingCart from '../js/home/ShoppingCart'
import Setting from './meLuo/Setting'
import OrderLuo from './meLuo/order/OrderLuo'
import OrderDetailLuo from './meLuo/order/OrderDetailLuo'
import OrderPraiseLuo from './meLuo/order/OrderPraiseLuo'
import PersonInfo from '../js/me/PersonInfo'
import CityChooser from '../js/address/CityChooser'
import OtherFoodHotSale from './homeLuo/OtherFoodHotSale'
import SearchAddress from '../js/address/SearchAddress'
import CommentList from './homeLuo/CommentList'
import SetNickName from './meLuo/SetNickName'
import Flagship from './homeLuo/Flagship'
import MyTicketRecord from './meLuo/MyTicketRecord'
import About from './meLuo/About'
import Agreement from './loginLuo/Agreement'
import SendCheckCode from './loginLuo/SendCheckCode'
import BindPhoneNum from './loginLuo/BindPhoneNum'
import SetPassword from './loginLuo/SetPassword'
import IWantOpenShop from './meLuo/IWantOpenShop'
const AppLuo = StackNavigator(
    {
        Root:{screen:Tab},
        Login:{screen:Login},
        WaterStation:{screen:WaterStation},
        ConfirmOrder:{screen:ConfirmOrder},
        QuickPay:{screen:QuickPay},
        PayResult:{screen:PayResult},
        AddressList:{screen:AddressList},
        TiketsViable:{screen:TiketsViable},
        TicketCell:{screen:TicketCell},
        TicketDetails:{screen:TicketDetails},
        TicketDetail:{screen:TicketDetail},
        TicketPage:{screen:TicketPage},
        TiketList:{screen:TiketList},
        ProductInfoLuo:{screen:ProductInfoLuo},
        ProductsDetailsLuo:{screen:ProductsDetailsLuo},
        DeliveryAddress:{screen:DeliveryAddress},
        AddOrEditAddress:{screen:AddOrEditAddress},
        Map:{screen:Map},
        HotSaleList:{screen:HotSaleList},
        Collection:{screen:Collection},
        MyTiketsLuo:{screen:MyTiketsLuo},
        MyTicketDetail:{screen:MyTicketDetail},
        ShoppingCart:{screen:ShoppingCart},
        Setting:{screen:Setting},
        Order:{screen:OrderLuo},
        OrderDetail:{screen:OrderDetailLuo},
        OrderPraise:{screen:OrderPraiseLuo},
        PersonInfo:{screen:PersonInfo},
        CityChooser:{screen:CityChooser},
        OtherFoodHotSale:{screen:OtherFoodHotSale},
        SearchAddress:{screen:SearchAddress},
        CommentList:{screen:CommentList},
        SetNickName:{screen:SetNickName},
        MyTiketsUsedLuo:{screen:MyTiketsUsedLuo},
        Flagship:{screen:Flagship},
        MyTicketRecord:{screen:MyTicketRecord},
        About:{screen:About},
        Agreement:{screen:Agreement},
        SendCheckCode:{screen:SendCheckCode},
        BindPhoneNum:{screen:BindPhoneNum},
        SetPassword:{screen:SetPassword},
        IWantOpenShop:{screen:IWantOpenShop},
    }
);

class App extends Component{

        componentDidMount() {
                //监听状态改变事件
                AppState.addEventListener('change', this.handleAppStateChange.bind(this));
        }
        componentWillUnmount() {
                //删除状态改变事件监听
                AppState.removeEventListener('change', this.handleAppStateChange.bind(this));
        }
        //状态改变响应
        handleAppStateChange = (appState) => {
                if (appState == 'active') {
                        this.checkUpdate();
                }
        }
        checkUpdate() {
                CodePushUtil.checkUpdate();
        }
        render(){
                return <AppLuo/>
        }
}

//import codePush from 'react-native-code-push'
//const codePushOptions = {checkFrequency: codePush.CheckFrequency.MANUAL};
//Enter = codePush(codePushOptions)(App);
Enter = App;
module.exports = Enter;

